<?php

include_once dirname(__FILE__) . "/../conf.php";

Log::init("Conf_test");

class Conf_test extends PHPUnit_Framework_TestCase
{
    public function test_load_with_invalid_ini_file()
    {
        $cur_dir = dirname(__FILE__);
        $cmd = "cp $cur_dir/../conf/conf.ini $cur_dir/../conf/conf.ini.old";
        passthru($cmd, $ret);
        $this->assertTrue($ret == 0);
        file_put_contents("$cur_dir/../conf/conf.ini", "this line is not ini file format");

        global $err_code;
        $ret = Conf::get("log.level");
        $this->assertTrue($ret == false);
        $this->assertTrue($err_code == ec_conf_error);

        $cmd = "mv $cur_dir/../conf/conf.ini.old $cur_dir/../conf/conf.ini";
        passthru($cmd, $ret);
        $this->assertTrue($ret == 0);
    }
    public function test_load_with_entry_not_found()
    {
        global $err_code;
        $ret = Conf::get("log.levelllllllllllllll");
        $this->assertTrue($ret == false);
        $this->assertTrue($err_code == ec_conf_error);
    }
}

?>
